package com.usian.controller;

import com.usian.pojo.User;
import com.usian.service.UserServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserServiceImpl userService;


    @RequestMapping("/{page}")
    public String showPage (@PathVariable String page){
            return page;



        }
        @RequestMapping("/addUser")
    public String addUser(User user){
            this.userService.addUser(user);
            return "ok";

        }
        @RequestMapping("/update")
    public String update(User user){
            this.userService.update(user);

            return "ok";
        }

    @RequestMapping("/listUser")
    public String listUser(Model model) {
        List<User> list = this.userService.listUser();
        model.addAttribute("list", list);
        return "list";
    }



}
